/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * MainFrame.java
 *
 * Created on 22.10.2009, 15:24:48
 */
package fertigproz;

import fertigproz.models.BaseTableModel;
import fertigproz.models.MitarbeiterModel;
import javax.swing.RowFilter;
import javax.swing.table.TableRowSorter;

/**
 *
 * @author zimmbi
 */
public class MainFrame extends javax.swing.JFrame {

    private MySQLDriver mysql;
    private MitarbeiterModel mymodel;

    /** Creates new form MainFrame */
    public MainFrame() {
        initComponents();
        mysql = new MySQLDriver("82.195.231.26", "fertigproz", "fertigproz", "fertigproz");
        if (mysql.connect()) {
            System.out.println("OK");
        } else {
            System.out.println("NOT OK");
        }


        mymodel = new MitarbeiterModel(mysql);

        jTable1.setModel(mymodel);

        RowFilter<BaseTableModel, Object> filter = new RowFilter<BaseTableModel, Object>() {

            public boolean include(Entry entry) {
                return true;
            }
        };

        TableRowSorter<BaseTableModel> sorter = new TableRowSorter<BaseTableModel>(mymodel);
        sorter.setRowFilter(filter);

        jTable1.setRowSorter(sorter);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();
        meinSuperClickButton = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jTable1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPane1.setViewportView(jTable1);

        meinSuperClickButton.setText("jButton1");
        meinSuperClickButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                meinSuperClickButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 563, Short.MAX_VALUE)
                    .addComponent(meinSuperClickButton, javax.swing.GroupLayout.Alignment.TRAILING))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 308, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 36, Short.MAX_VALUE)
                .addComponent(meinSuperClickButton)
                .addContainerGap())
        );

        meinSuperClickButton.getAccessibleContext().setAccessibleName("");

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void meinSuperClickButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_meinSuperClickButtonActionPerformed
       new AlleUnterteile(mysql).setVisible(true);

    }//GEN-LAST:event_meinSuperClickButtonActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new MainFrame().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTable jTable1;
    private javax.swing.JButton meinSuperClickButton;
    // End of variables declaration//GEN-END:variables
}
